import {http, PureHttp} from '@/utils/http'

interface ResponseType extends Promise<any> {
  data?: object;
  code?: number;
  message?: string;
}

/*
通过用户名获取用户id
*/
export const regionTree = (): ResponseType => http.request(
  'get',
  '/region/tree',
)

/*
通过用户名获取用户id
*/
export const addStation = (params: any): ResponseType => http.request(
  'post',
  '/station/add',
  {data: params}
)

/*
通过用户名获取用户id
*/
export const deleteStation = (params: any): ResponseType => http.request(
  'delete',
  '/station/remove',
  {params}
)

/*
通过用户名获取用户id
*/
export const updateStation = (params: any): ResponseType => http.request(
  'put',
  '/station/update',
  {data: params}
)

/*
通过用户名获取用户id
*/
export const pageStation = (params: any): ResponseType => http.request(
  'post',
  '/station/page',
  {data: params}
)

/*
批量导入站点信息
*/
export const uploadExcel = (params: any): ResponseType => PureHttp.axiosInstance.post(
  '/station/uploadExcel',
  params, {headers: {'Content-Type': 'application/octet-stream'}}
)

// export const uploadExcel = (params: any): ResponseType => PureHttp.axiosInstance.post(
//   '/station/uploadExcel',
//   params, {headers: {'Content-Type': 'multipart/form-data'}}
// )

export const upgradeDevice = (data: any): ResponseType => PureHttp.axiosInstance.post(
  '/device/upgradeDevice', data
)


export const statistic = (): ResponseType => http.request(
  'get',
  '/station/statistic'
)



/*
获取公共设备信息
*/
export const getRegionDeviceConfig = (params: object): ResponseType => http.request(
  'get',
  '/device/getRegionDeviceConfig',
  {params},
)

/*
获取单个站点的信息
*/
export const getDeviceConfig = (params: object): ResponseType => http.request(
  'get',
  '/device/getDeviceConfig',
  {params},
)



/*
更新设备
*/
export const updateConfig = (params: any): ResponseType => http.request(
  'post',
  '/device/updateConfig',
  {data: params}
)
